package com.shudai.largescreen.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shudai.largescreen.pojo.Dept;
import com.shudai.largescreen.pojo.User;
import com.shudai.largescreen.pojo.vo.AllCityAmount;
import com.shudai.largescreen.pojo.vo.ChartData;
import com.shudai.largescreen.pojo.vo.ChartDataData;
import com.shudai.largescreen.pojo.vo.DailyChartData;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface DeptMapper extends BaseMapper<User> {
    @Select({
            "<script> ",
            "SELECT count(s.id) total , d.id finish  ",
            "from sys_user s,sys_dept d,sd_tool_man_info sd",
            "<where> 1=1 and  s.dept_id = d.id and  sd.user_id = s.id",
            " and s.enabled = 1 ",
            "<if test='city != null and city != \"\" '> ",
            "and sd.city = #{city} ",
            "</if> ",

            "<if test='province != null and province != \"\" '> ",
            "and sd.province = #{province} ",
            "</if> ",

            "<if test='teamName != null and teamName != \"\" '> ",
            "and d.name = #{teamName} ",
            "</if> ",

            "</where> ",
            "GROUP BY d.id",
            "</script> ",
    })
    List<AllCityAmount> findDeptNumber(@Param("province") String province,
                                 @Param("city") String city,
                                 @Param("teamName") String teamName);

    @Select({
            " SELECT",
            "count(o.id) ",
            "FROM ",
            "sd_order o ,sys_user s ",
            "WHERE ",
            " o.order_time between #{startDate} and #{endDate}  ",
            " and o.tool_man_id = s.id and s.dept_id = #{deptId}"
    })
    String findOrderDaily(@Param("deptId") Integer deptId,
                          @Param("startDate") LocalDateTime startDate,
                          @Param("endDate") LocalDateTime endDate);

    @Select({
            " SELECT",
            "count(o.id) ",
            "FROM ",
            "sd_visit_user_record o ,sys_user s ",
            "WHERE ",
            " o.created_at between #{startDate} and #{endDate}  ",
            " and o.tool_man_id = s.id and s.dept_id = #{deptId}"
    })
    String findVisitDaily(@Param("deptId") Integer deptId,
                          @Param("startDate") LocalDateTime startDate,
                          @Param("endDate") LocalDateTime endDate);

    @Select({
            "SELECT ",
            "count( o.id ) ",
            "FROM ",
            " sd_order o,sys_user s ",
            "WHERE ",
            " o.order_time  between #{startDate} and #{endDate} ",
            " and o.tool_man_id = s.id and s.dept_id = #{deptId} "
    })
    String findOrderMoth(@Param("deptId") Integer deptId,
                         @Param("startDate") LocalDateTime startDate,
                         @Param("endDate") LocalDateTime endDate);


    // DATE_FORMAT( o.order_time, '%Y%m' ) = DATE_FORMAT(CURDATE( ),'%Y%m')
    @Select({
            "SELECT ",
            "count( o.id ) ",
            "FROM ",
            " sd_visit_user_record o,sys_user s ",
            "WHERE ",
            " o.created_at  between #{startDate} and #{endDate} ",

            " and o.tool_man_id = s.id and s.dept_id = #{deptId} "
    })
    String findVisitMoth(@Param("deptId") Integer deptId,
                         @Param("startDate") LocalDateTime startDate,
                         @Param("endDate") LocalDateTime endDate);

    @Select({
            "<script> ",
            "SELECT  s.nickname name,s.created_at time ,s.id id ,sd.province  province,sd.city  city,  d.name deptName",
            "from sys_user s ,sys_dept d ,sd_tool_man_info sd  ",
            "<where> 1=1 and  s.dept_id = d.id and s.id=sd.user_id and s.enabled = 1 ",
            "<if test='city != null and city != \"\" '> ",
            "and sd.city = #{city} ",
            "</if> ",

            "<if test='province != null and province != \"\" '> ",
            "and sd.province = #{province} ",
            "</if> ",

            "<if test='teamName != null and teamName != \"\" '> ",
            "and d.name = #{teamName} ",
            "</if> ",

            "</where> ",
            "GROUP BY s.nickname,s.created_at , s.id ,sd.province ,sd.city ,  d.name ",

            "</script> "
    })
    List<ChartData> findSalles(@Param("province") String province,
                               @Param("city") String city,
                               @Param("teamName") String teamNam);


    //            " and DATE_FORMAT( o.order_time, '%Y%m' ) = DATE_FORMAT(CURDATE( ),'%Y%m') ",
    @Select({
            "<script>",
            "SELECT  COUNT(o.id) data1,o.tool_man_name name,u.id id ",
            "from sd_order o,sys_user u ",
            "WHERE o.tool_man_id = u.id ",
            " and o.order_time between #{startDate} and #{endDate} ",
            "and o.tool_man_id in ",
            " <foreach collection=\"ids\" item=\"userId\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
            "#{userId}",
            "</foreach>",
            "GROUP BY o.tool_man_name,u.id",
            "</script>"
    })
    List<ChartDataData> findDeptMoth(@Param("ids") List<Long> collect,
                                     @Param("startDate") LocalDateTime startDate,
                                     @Param("endDate") LocalDateTime endDate);


    //            " and DATE_FORMAT( o.created_at, '%Y%m' ) = DATE_FORMAT(CURDATE( ),'%Y%m') ",
    @Select({
            "<script>",
            "SELECT  COUNT(o.id) data1,u.nickname name ,u.id id ",
            "from sd_user_record o,sys_user u,sd_tool_man_info sd ",
            "WHERE o.tool_man_id = u.id and sd.user_id=u.id ",

            " and o.created_at between #{startDate} and #{endDate} ",
            "and  o.tool_man_id in ",

            " <foreach collection=\"ids\" item=\"userId\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
            "#{userId}",
            "</foreach>",

            "GROUP BY u.nickname ,u.id",
            "</script>"
    })
    List<ChartDataData> findVititMoth(@Param("ids") List<Long> collect,
                                      @Param("startDate") LocalDateTime startDate,
                                      @Param("endDate") LocalDateTime endDate);

    //           " and DATE_FORMAT( o.created_at, '%Y%m' ) = DATE_FORMAT(CURDATE( ),'%Y%m') ",
    @Select({
            "<script>",
            "SELECT  COUNT(o.id) data1,u.nickname name,u.id id ",
            "from  sd_visit_user_record o,sys_user u,sd_tool_man_info sd ",
            "WHERE o.tool_man_id = u.id and sd.user_id=u.id ",

            " and o.created_at between #{startDate} and #{endDate} ",
            "and  o.tool_man_id in ",

            " <foreach collection=\"ids\" item=\"userId\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
            "#{userId}",
            "</foreach>",

            "GROUP BY u.nickname,u.id",
            "</script>"
    })
    List<ChartDataData> findReVititMoth(@Param("ids") List<Long> collect,
                                        @Param("startDate") LocalDateTime startDate,
                                        @Param("endDate") LocalDateTime endDate);

    @Select({
            "<script>",

            "SELECT  s.nickname salesman ,s.id id",
            "from sys_user s ,sys_dept d ,sd_tool_man_info sd  ",
            "<where> 1=1 and  s.dept_id = d.id and s.id=sd.user_id and s.enabled = 1 ",

            "<if test='city != null and city != \"\" '> ",
            "and sd.city = #{city} ",
            "</if> ",

            "<if test='province != null and province != \"\" '> ",
            "and sd.province = #{province} ",
            "</if> ",

            "<if test='teamName != null and teamName != \"\" '> ",
            "and d.name = #{teamName} ",
            "</if> ",

            "</where>",
            "GROUP BY s.nickname, s.id ",

            "</script>"

    })
    List<DailyChartData> findDeptNumbers(@Param("province") String province,
                                         @Param("city") String city,
                                         @Param("teamName") String teamNam);

    @Select({
            "<script>",
            "SELECT ",
            "  count(o.id) as orderNew ,o.tool_man_id id ,sum(o.total_number) orderUnitNew",
            "from sd_order o  ",
            "WHERE o.tool_man_id in",

            " <foreach collection=\"ids\" item=\"userId\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
            "#{userId}",
            "</foreach>",

            "and o.order_time BETWEEN #{startDate} and #{endDate}  ",
            " ",
            "GROUP BY o.tool_man_id  ",
            " order by orderUnitNew ",
            "</script>"
    })
    List<DailyChartData> findOrderDailyNow(@Param("ids") List<Long> collect,
                                           @Param("startDate") LocalDateTime startDate,
                                           @Param("endDate") LocalDateTime endDate);


    @Select({
            "<script>",
            "SELECT ",
            "  count(o.id) as orderConfirm ,o.tool_man_id id ,sum(o.total_number) orderConfirmUnit ,sum(amount) orderConfirmMoney",
            "from sd_order o  ",
            "WHERE o.tool_man_id in",

            " <foreach collection=\"ids\" item=\"userId\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
            "#{userId}",
            "</foreach>",

            "and o.order_time BETWEEN #{startDate} and #{endDate}  ",
            " and o.order_state > 6 ",
            "GROUP BY o.tool_man_id  ",
            " order by orderConfirmMoney ",
            "</script>"
    })
    List<DailyChartData> findOrderTrue(@Param("ids") List<Long> collect,
                                       @Param("startDate") LocalDateTime startDate,
                                       @Param("endDate") LocalDateTime endDate);

    @Select({
            "<script>",
            "SELECT ",
            "  count(o.id) as visit ,o.tool_man_id id ",
            "from sd_user_record o  ",
            "WHERE o.tool_man_id in",

            " <foreach collection=\"ids\" item=\"userId\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
            "#{userId}",
            "</foreach>",

            "and o.created_at  BETWEEN #{startDate} and #{endDate} ",
            "  ",
            "GROUP BY o.tool_man_id  ",
            "</script>"
    })
    List<DailyChartData> findVisitDailyNow(@Param("ids") List<Long> collect,
                                           @Param("startDate") LocalDateTime startDate,
                                           @Param("endDate") LocalDateTime endDate);


    @Select({
            "<script>",
            "SELECT ",
            "  count(o.id) as revisit ,o.tool_man_id id ",
            "from sd_visit_user_record o  ",
            "WHERE o.tool_man_id in",

            " <foreach collection=\"ids\" item=\"userId\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
            "#{userId}",
            "</foreach>",

            "and o.created_at  BETWEEN #{startDate} and #{endDate} ",
            "  ",
            "GROUP BY o.tool_man_id  ",
            "</script>",
    })
    List<DailyChartData> findVisitDailyRe(@Param("ids") List<Long> collect,
                                          @Param("startDate") LocalDateTime startDate,
                                          @Param("endDate") LocalDateTime endDate);


//                "and  sd.province = #{province}  and sd.city= #{city} and d.name= #{teamName}",
    @Select({
            "<script>",
            "SELECT  s.nickname name,s.created_at time ,s.id id ,sd.city city  ,d.name deptName,count(o.id) total",
            "from sys_user s ,sys_dept d ,sd_tool_man_info sd,sd_order o  ",
            "<where> 1=1 and  s.dept_id = d.id and s.id=sd.user_id and s.enabled = 1 and s.created_at BETWEEN #{startDate} and #{endMoth}  ",
            " and o.tool_man_id = s.id  and o.on_cancel = 0 " +
                    " and o.order_time BETWEEN #{startDate}  " +
                    " AND #{endMoth}  ",

            "<if test='userId != null and userId != \"\" '> ",
            "and  s.id = #{userId} ",
            "</if> ",
            " </where> ",

            "GROUP BY s.nickname,s.created_at , s.id,sd.city ,d.name ",
            " ORDER BY total desc ",
            "</script>",
    })
    List<ChartDataData> findOrderEntryTwos(
                                           @Param("userId") String userId,
                                           @Param("startDate") LocalDateTime startDate,
                                           @Param("endMoth") LocalDateTime endMoth);

    //and s.created_at BETWEEN #{startDate} and #{endMoth}
    @Select({
            "<script>",
            "SELECT  s.nickname name,s.created_at time ,s.id id ,sd.city city  ,d.name deptName,count(o.id) total",
            "from sys_user s ,sys_dept d ,sd_tool_man_info sd,sd_order o  ",
            "<where> 1=1 and  s.dept_id = d.id and s.id=sd.user_id and s.enabled = 1   ",
            " and o.tool_man_id = s.id  and o.on_cancel = 0 " +
                    " and o.order_time BETWEEN #{startDate}  " +
                    " AND #{endMoth}  ",
            "and  s.id in ",

            " <foreach collection=\"ids\" item=\"ids\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
            "#{ids}",
            "</foreach>",

            " </where> ",

            "GROUP BY s.nickname,s.created_at , s.id,sd.city ,d.name ",
            " ORDER BY total desc ",
            "</script>",
    })
    List<ChartDataData> findOrderEntryTwos1(
                    @Param("ids") List<Long> userId,
                    @Param("startDate") LocalDateTime startDate,
                    @Param("endMoth") LocalDateTime endMoth);


//    @Select({
//            "<script>",
//            "SELECT  s.nickname name,s.created_at time ,s.id id ,sd.city city  ,d.name deptName ",
//            "from sys_user s ,sys_dept d ,sd_tool_man_info sd  ",
//            "<where> 1=1 and  s.dept_id = d.id and s.id=sd.user_id and s.enabled = 1   ",
//            "   " +
//                    "  and s.created_at  BETWEEN #{startDate}  " +
//
//            "and  s.id in ",
//
//            " <foreach collection=\"ids\" item=\"ids\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
//            "#{ids}",
//            "</foreach>",
//
//            " </where> ",
//
//            "GROUP BY s.nickname,s.created_at , s.id,sd.city ,d.name ",
//            "</script>",
//    })

//          "   " +
//                    " and s.created_at  BETWEEN #{startDate}  " +
//                    " AND #{endMoth}  ",
//            " ",
    @Select({
            "<script>",
            "SELECT  s.nickname name,s.created_at time ,s.id id ,sd.city city  ,d.name deptName ",
            "from sys_user s ,sys_dept d ,sd_tool_man_info sd  ",
            "<where> 1=1 and  s.dept_id = d.id and s.id=sd.user_id and s.enabled = 1   ",

            "and  s.id in ",
            " <foreach collection=\"ids\" item=\"ids\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
            "#{ids}",
            "</foreach>",
            " </where> ",

            "GROUP BY s.nickname,s.created_at , s.id,sd.city ,d.name ",

            "</script>",
    })
    List<ChartDataData> findOrderEntryTwos2(
            @Param("ids") List<Long> userId,
            @Param("startDate") LocalDateTime startDate,
            @Param("endMoth") LocalDateTime endMoth);

//
//            "SELECT count(o.id) total,o.order_time timeLocal,u.dept_id id ",
//            "FROM sd_order o ,sys_user u ,sd_tool_man_info sd ,sys_dept t ",
//            "where 1=1 and u.id = o.tool_man_id  and o.on_cancel = 0 and t.id = u.dept_id",
//            " and o.order_time BETWEEN #{startDate} and #{endMoth} ",
//            " and  sd .province = #{province} and sd.city = #{city} and t.name=#{teamName}",
//            "GROUP BY u.dept_id ,o.order_time",
//
//
    //
    //  and  sd .province = #{province} and sd.city = #{city} and t.name=#{teamName}
//
//  "#{userId}",
        @Select({

       "<script>",
                "SELECT count(o.id) total,o.order_time timeLocal,u.id id FROM sd_order o ,sys_user u ,sd_tool_man_info sd  " +
                "<where> 1=1 and u.id = o.tool_man_id  and o.on_cancel = 0 " +
                        " and o.order_time BETWEEN #{startDate} and #{endMoth} " +

               " and u.id = sd.user_id and u.id = " ,

            "#{ids}",




                " </where> ",
               "GROUP BY u.id ,o.order_time",
                "</script>",
    })
    List<ChartDataData> findOrderMothDept(@Param("ids") Long userId,
                                          @Param("startDate") LocalDateTime startDate,
                                          @Param("endMoth") LocalDateTime endMoth);


    @Select({

            "<script>",
            "SELECT count(o.id) total,o.order_time timeLocal,u.id id FROM sd_order o ,sys_user u ,sd_tool_man_info sd  " +
                    "<where> 1=1 and u.id = o.tool_man_id  and o.on_cancel = 0 " +
                    " and o.order_time BETWEEN #{startDate} and #{endMoth} " +

                    " and u.id = sd.user_id and u.id in " ,

            " <foreach collection=\"ids\" item=\"ids\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
            "#{ids}",
            "</foreach>",



            " </where> ",
            "GROUP BY u.id ,o.order_time",
            "</script>",
    })
    List<ChartDataData> findOrderMothDept1(@Param("ids") List<Long> userId,
                                          @Param("startDate") LocalDateTime startDate,
                                          @Param("endMoth") LocalDateTime endMoth);

//               "sd .province = #{province} and sd.city = #{city} and t.name=#{teamName} " +
//        " <foreach collection=\"ids\" item=\"ids\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
//            "#{ids}",
//            "</foreach>",
    @Select({
            "<script>",
            "SELECT count(o.id) total,o.created_at timeLocal,u.id id FROM sd_user_record o ,sys_user u ,sd_tool_man_info sd ,sys_dept t\n" +
                    "<where> 1=1 and u.id = o.tool_man_id  and t.id = u.dept_id and o.created_at BETWEEN #{startDate} and #{endMoth} " +
                    "and u.id = sd.user_id  " +
                    " and u.id = " +
            "#{userId}",

            " </where> ",

                    "GROUP BY u.dept_id ,o.created_at ",
            "</script>",
    })
    List<ChartDataData> findVisitMothDept(@Param("userId") Long userId,
                                          @Param("startDate") LocalDateTime startDate,
                                          @Param("endMoth") LocalDateTime endMoth);

    @Select({
            "<script>",
            "SELECT count(o.id) total,o.created_at timeLocal,u.id id FROM sd_visit_user_record o ,sys_user u ,sd_tool_man_info sd ,sys_dept t\n" +
                    "<where> 1=1 and u.id = o.tool_man_id  and t.id = u.dept_id and o.created_at BETWEEN #{startDate} and #{endMoth} " +
                    "and u.id = sd.user_id  " +
                    " and u.id = " +
                    "#{userId}",

            " </where> ",

            "GROUP BY u.dept_id ,o.created_at ",
            "</script>",
    })
    List<ChartDataData> findVisitMothDept1(@Param("userId") Long userId,
                                          @Param("startDate") LocalDateTime startDate,
                                          @Param("endMoth") LocalDateTime endMoth);

    @Select({
            "<script>",
            "SELECT count(v.id) total  , u.id id , u.nickname name " +
                    "FROM sd_visit_user_record v,sys_user u  " +
                    "WHERE  u.id = v.tool_man_id and u.enabled = 1 and u.id =   " +
            "#{userId}",

            " and v.created_at BETWEEN #{startDate} and #{endMoth}  ",
            " GROUP BY u.id ,u.nickname ",
            "</script> "
    })
    List<ChartDataData> findVisitMothSales(@Param("userId") Long collect,
                                           @Param("startDate") LocalDateTime startDate,
                                           @Param("endMoth") LocalDateTime endMoth);

    @Select({
            "<script>",
            "SELECT count(v.id) total  , u.id id , u.nickname name " +
                    "FROM sd_visit_user_record v,sys_user u  " +
                    "WHERE  u.id = v.tool_man_id and u.enabled = 1 and u.id in   " +


                    " <foreach collection=\"ids\" item=\"ids\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
            "#{ids}",
            "</foreach>",



            " and v.created_at BETWEEN #{startDate} and #{endMoth}  ",
            " GROUP BY u.id ,u.nickname ",
            "</script> "
    })
    List<ChartDataData> findVisitMothSales4(@Param("ids") List<Long> collect,
                                           @Param("startDate") LocalDateTime startDate,
                                           @Param("endMoth") LocalDateTime endMoth);


    @Select({
            "<script>",
            "SELECT count(v.id) total  , u.id id , u.nickname name " +
                    "FROM sd_user_record v,sys_user u  " +
                    "WHERE  u.id = v.tool_man_id and u.enabled = 1 and u.id in   " +
                    " <foreach collection=\"ids\" item=\"ids\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
            "#{ids}",
            "</foreach>",

            " and v.created_at BETWEEN #{startDate} and #{endMoth}  ",

            " GROUP BY u.id ,u.nickname ",
            "</script> "
    })
    List<ChartDataData> findVisitMothSales3(@Param("ids") List<Long> collect,
                                            @Param("startDate") LocalDateTime startDate,
                                            @Param("endMoth") LocalDateTime endMoth);

    @Select({
            "<script>",
            "SELECT count(v.id) total  , u.id id , u.nickname name " +
                    "FROM sd_user_record v,sys_user u  " +
                    "WHERE  u.id = v.tool_man_id and u.enabled = 1 and u.id =   " +
                    "#{userId}",

            " and v.created_at BETWEEN #{startDate} and #{endMoth}  ",

            " GROUP BY u.id ,u.nickname ",
            "</script> "
    })
    List<ChartDataData> findVisitMothSales1(@Param("userId") Long collect,
                                           @Param("startDate") LocalDateTime startDate,
                                           @Param("endMoth") LocalDateTime endMoth);

    @Select({
            "<script>",
            "SELECT  s.nickname name,s.created_at time ,s.id id ,sd.city city  ,d.name deptName ",
            "from sys_user s ,sys_dept d ,sd_tool_man_info sd  ",
            "<where> 1=1 and  s.dept_id = d.id and s.id=sd.user_id and s.enabled = 1   ",
            "   " +
                    " and s.created_at  BETWEEN #{startDate}  " +
                    " AND #{endMoth}  ",
            " ",

            " </where> ",

            "GROUP BY s.nickname,s.created_at , s.id,sd.city ,d.name ",

            "</script>",
    })
    List<ChartDataData> findVisitMothSales2(@Param("startDate") LocalDateTime startDate,
                                            @Param("endMoth") LocalDateTime endMoth);

    @Select({
            "<script>",
            "SELECT count(o.id) total, u.id id,sum(o.amount) amount " +
                    " FROM sd_order o,sys_user u " +
                    "WHERE   u.id = o.tool_man_id  and o.on_cancel = 0 and u.id in " +

                    " <foreach collection=\"ids\" item=\"ids\" index=\"index\" open=\"(\" separator=\",\" close=\")\">",
            "#{ids}",
            "</foreach>",

            " and o.order_time BETWEEN #{startDate} and #{endMoth}  ",
            "GROUP BY u.id ",
            "</script> "
    })
    List<ChartDataData> findOrderMothSales(@Param("ids") List<Long> collect,
                                           @Param("startDate") LocalDateTime startDate,
                                           @Param("endMoth") LocalDateTime endMoth);

    @Select({
            "SELECT  COUNT(o.id) data1",
            "from sd_visit_user_record o ",
            "WHERE o.tool_man_id = #{id} and ",
            "PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( o.created_at, '%Y%m' ) )=#{time} "

    })
    Integer findVititMoths(@Param("id") Long userId,
                           @Param("time") Integer time);

    @Select({
            "SELECT  COUNT(o.id) finish ,sum(o.amount) total",
            "from sd_order o ",
            "WHERE o.tool_man_id = #{id} and o.on_cancel and ",
            "PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( o.order_time, '%Y%m' ) )=#{time} "

    })
    AllCityAmount findOrderMoths(@Param("id") Long userId, @Param("time") Integer time);

    @Select({
            "SELECT  COUNT(o.id) data1",
            "from sd_visit_user_record o ",
            "WHERE o.tool_man_id = #{id} and ",
            "DATE_FORMAT( o.created_at, '%Y%m' ) = DATE_FORMAT(CURDATE( ),'%Y%m') "
    })
    Integer findVititMothNow(@Param("id") Long userId);

    @Select({
            "SELECT  COUNT(o.id) finish ,sum(o.amount) total ",
            "from sd_order o ",
            "WHERE o.tool_man_id = #{id} and ",
            "DATE_FORMAT( o.order_time, '%Y%m' ) = DATE_FORMAT(CURDATE( ),'%Y%m') "
    })
    AllCityAmount findOrderMothNow(@Param("id") Long userId);


}
